import os
import sys
# import os,sys
# sys.path.append(os.getcwd())
# # os.getcwd()用于获取当前工作目录

# 定义搜索优先顺序
# import sys
# sys.path.insert(1, "./model")
# sys.path.insert(1, "./crnn")定义搜索路径的优先顺序，序号从0开始，表示最大优先级，sys.path.insert()加入的也是临时搜索路径，程序退出后失效。

# 调试信息
print("Current file:", __file__)
print("Current working directory:", os.getcwd())

# 获取app目录的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
app_dir = os.path.dirname(os.path.dirname(current_dir))

print("App directory:", app_dir)
print("Current sys.path:", sys.path)

# 移除当前目录路径（如果存在）
if current_dir in sys.path:
    sys.path.remove(current_dir)

# 确保app目录在Python路径的最前面
if app_dir in sys.path:
    sys.path.remove(app_dir)
sys.path.insert(0, app_dir)

print("Updated sys.path:", sys.path)

# 强制设置PYTHONPATH
os.environ['PYTHONPATH'] = '/app'
sys.path.insert(0, '/app')

# 现在尝试导入
try:
    from config.system import LOG_LEVEL, LOG_FILE, LOG_BAK, LOG_MAX
except ImportError as e:
    print(f"Failed to import config.system: {e}")
    # 设置默认值
    LOG_LEVEL = "INFO"
    LOG_FILE = "app"
    LOG_BAK = 5
    LOG_MAX = 10 * 1024 * 1024
